﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head><link rel="stylesheet" href="${ctx}/common/common.css">
    <title>Title</title>
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
    <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>
    
</head>
<body>
<form class="layui-form"  id="form" action="${ctx}/label/saveLabel"  >
    <input type="hidden" name="id" id="id" value="${label.id}" />
    <div class="layui-form-item layui-col-md5" style="margin-top: 50px">
        <label class="layui-form-label">申请单号</label>
        <div class="layui-input-block">
            <input type="text"  required value="${label.code}"  readonly="readonly"   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">申请人</label>
        <div class="layui-input-block">
            <input type="text"  value="${label.creatorName}" readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">申请时间</label>
        <div class="layui-input-block">
            <input type="text"    value="<fmt:formatDate value='${label.createTime}' pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">产品名称</label>
        <div class="layui-input-block">
            <input type="text"    value="${product.name}" readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">规格</label>
        <div class="layui-input-block">
            <input type="text"  value="${product.specifications}" readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">单位</label>
        <div class="layui-input-block">
            <input type="text" value="${product.unit}" readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">生成批次</label>
        <div class="layui-input-block">
            <input type="text" value="${batch.code}" readonly="readonly"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">生产数量</label>
        <div class="layui-input-block">
            <input type="text"  value="${count}" readonly="readonly"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
      		<textarea readonly="readonly" style="width:100%;height:100px;"  class="layui-input" rows="5" cols="5">${label.remarks}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">申请数量</label>
        <div class="layui-input-block">
            <input type="text"  value="${label.quantity}" readonly="readonly"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">发放数量<span style="color: red">*</span></label>
        <div class="layui-input-block">
            <input type="text" name="grantQuantity" lay-verify=number id="grantQuantity"  placeholder="请输入发放数量"   autocomplete="off" class="layui-input">
        </div>
    </div>
        <div class="layui-form-item layui-col-md5">
        <label class="layui-form-label">审批意见</label>
        <div class="layui-input-block">
      		<textarea name="content" id="content" style="width:100%;height:100px;"  class="layui-input" rows="5" cols="5" placeholder="请输入审批意见"></textarea>
        </div>
    </div>
 <div class="layui-form-item">
    <label class="layui-form-label">审批通过</label>
    <div class="layui-input-block">
      <input type="checkbox" id="open" checked name="open" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
    </div>
  </div>
    <c:if test="${empty detail}">
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" type="button" id="formBtn"  >立即提交</button>
                <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
            </div>
        </div>
    </c:if>
</form>
<script>

 //Demo
layui.use('form', function(){
    var  form = layui.form;
    //监听提交
 

    document.getElementById("formBtn").addEventListener("click",function(){
    	   // window.history.back();
    	   var open=document.getElementById("open").checked;
    	   var grantQuantity=document.getElementById("grantQuantity").value;
    	   var id=document.getElementById("id").value;
    	   var content=document.getElementById("content").value;
    	   var num=/^[0-9]*[1-9][0-9]*$/;
    	   if(open==false){
    		   window.location.href="${ctx}/label/saveLabel?id="+id+"&open="+open+"&content="+content+"&grantQuantity="+grantQuantity;
    	   }else if(grantQuantity==""){
    		  // layer.alert("请输入发放数量", {icon: 2});
    		   alert("请输入发放数量");
    	   }else if(!num.test(grantQuantity)){
    		   alert("请输入正整数")
    	   }else{
    		   window.location.href="${ctx}/label/saveLabel?id="+id+"&open="+open+"&content="+content+"&grantQuantity="+grantQuantity;
    	   }
    	 })

}); 
document.getElementById("rollback").addEventListener("click",function(){
    window.history.back();
})




</script>
</body>
</html>



